﻿using huqiang.Communication;
using huqiang.DataSet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace huqiang.ProtoDataPro
{
    public class RecordCmd
    {
        public const UInt16 AssetsBundle = 0;
        public const UInt16 Open = 1;
        public const UInt16 Name = 2;
    }
    public class RecordDataPro
    {
        public static void Handle(KcpUser user, UInt16 cmd, byte[] dat)
        {
            switch (cmd)
            {
                case RecordCmd.AssetsBundle:
                    ProAssetsBundle(user, dat);
                    break;
                case RecordCmd.Open:
                    OpenRecord(user);
                    break;
                case RecordCmd.Name:
                    SetName(user, dat);
                    break;
            }
        }
        static void ProAssetsBundle(KcpUser user, byte[]  dat)
        {
            //var protouser = user as NetUser;
            //protouser.OpenOrCreateLog();
            //var ud = protouser.record;
            //if (ud == null)
            //    return;
            //try
            //{
            //    ABRecord ab =ProtoSerializer.Deserialize<ABRecord>(dat);
            //    if (ab != null)
            //    {
            //        StringBuilder builder = new StringBuilder();
            //        if (ab.bundles != null)
            //        {
            //            for (int i = 0; i < ab.bundles.Length; i++)
            //            {
            //                builder.Append(ab.bundles[i]);
            //                builder.Append(';');
            //            }
            //            string str = builder.ToString();
            //            ud.Write(ab.time.ToString(), "=", str, "\n");
            //        }
            //    }
            //}
            //catch (Exception ex)
            //{
            //    OutLog.WriteLine(ex.StackTrace);
            //}

        }
        static void OpenRecord(KcpUser user)
        {
            //var soc = user as NetUser;
            //soc.OpenOrCreateLog();
        }
        static void SetName(KcpUser user, byte[] dat)
        {
            //var soc = user as NetUser;
            //var ud = soc.userData;
            //if (ud != null)
            //    ud.name = str;
        }
    }
}
